package com.raffles.oa.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.system.common.Page;
import com.raffles.oa.domain.CompanyElectricCharge;
import com.raffles.oa.domain.ElectricCharge;
import com.raffles.oa.dao.IElectricChargeDAO;
import com.system.util.PersistUtil;
import com.raffles.oa.sql.sqlid.ElectricChargeSqlID;
/**
 * : t_raffles_electric_charge
 * 
 * 
 * @author Gen
 */
public class ElectricChargeDAOImpl implements IElectricChargeDAO{

	public ElectricCharge insertElectricCharge(ElectricCharge bean){
		return PersistUtil.insert(bean, ElectricChargeSqlID.INSERT);
	}

	public boolean deleteElectricCharge(String elchGuid){
		PersistUtil.delete(elchGuid, ElectricChargeSqlID.DELETE);
		return true;
	}	

	public ElectricCharge updateElectricCharge(ElectricCharge bean){
		return PersistUtil.update(bean, ElectricChargeSqlID.UPDATE);
	}	

	public ElectricCharge loadElectricCharge(String elchGuid){
		return PersistUtil.query(new ElectricCharge().getClass(), elchGuid);
	}

	public List<ElectricCharge> queryList(Map<String,Object> param,Page page){
		page.setCount(PersistUtil.countSpecial(param, ElectricChargeSqlID.QUERY));
		return PersistUtil.querySpecial(param, ElectricChargeSqlID.QUERY, page.getFullOrderBy(), page.getOffset(), page.getLimit());
	}

	public List<CompanyElectricCharge> queryPageListCompanyElectricCharge(Map<String, Object> param, Page page) {
		page.setCount(PersistUtil.countSpecial(param, ElectricChargeSqlID.QUERY_COMPANY_ELECTRIC_CHARGE));
		return PersistUtil.querySpecial(param, ElectricChargeSqlID.QUERY_COMPANY_ELECTRIC_CHARGE, page.getFullOrderBy(), page.getOffset(), page.getLimit());
	}

	public List<CompanyElectricCharge> queryListCompanyElectricCharge(Map<String, Object> param) {
		return PersistUtil.query(param, ElectricChargeSqlID.QUERY_COMPANY_ELECTRIC_CHARGE);
	}

	public CompanyElectricCharge queryCompanyElectricCharge(String shopCode, String electricMeterNo, String elchPeriod) {
		CompanyElectricCharge result = null;
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("elinMeterNo", electricMeterNo);
		param.put("coinCode", shopCode);
		param.put("elchPeriod", elchPeriod);
		
		List<CompanyElectricCharge> resultList = PersistUtil.query(param, ElectricChargeSqlID.QUERY_COMPANY_ELECTRIC_CHARGE);
		if(!resultList.isEmpty())
			result = resultList.get(0);
		
		return result;
	}

}
